package com.zhongyu.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zhongyu.pojo.KucunBiandong;
import com.zhongyu.pojo.KucunPandian;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface KuCunPdMapper extends BaseMapper<KucunPandian> {

    @Select("SELECT t1.*,t2.id ,t2.*,t3.id,t3.*,t4.id,t4.* FROM smbms_kucun_pandian t1\n" +
            "            LEFT  JOIN smbms_user t2 ON t1.user_Ids=t2.id\n" +
            "            LEFT JOIN  smbms_cangku t3 ON t1.cangku_id=t3.id\n" +
            "            LEFT JOIN  smbms_goods t4 ON t1.`goods_id`=t4.id ${ew.customSqlSegment}")
    @ResultMap("kucunPdRm")
    List<KucunPandian> findAll(Page page , @Param("ew") Wrapper wrapper);

    @Select("SELECT t1.*,t2.id ,t2.*,t3.id,t3.*,t4.id,t4.* FROM smbms_kucun_pandian t1\n" +
            "LEFT  JOIN smbms_user t2 ON t1.user_Ids=t2.id\n" +
            "LEFT JOIN smbms_cangku t3 ON t1.cangku_id=t3.id\n" +
            "LEFT JOIN smbms_goods t4 ON t1.`goods_id`=t4.id  where t1.cangku_id=#{cangkuId} and t1.goods_id=#{goodsId}")
    @ResultMap("kucunPdRm")
    List<KucunPandian>findById(Integer cangkuId,Integer goodsId);
}
